import React from "react";
import styles from './index.module.scss';
import classnames from 'classnames';
import {prompt} from '@/utils';
import {IconFont} from '@/components';
import {EnumDvActions} from "@/pages/dv/constants/EnumHeaderToolbar";
import dvTool from "@/pages/dv/dvTool";
import store from '@/stores/dvEditor';

/**
 * 大屏操作行为枚举
 // * @param actions
 * @constructor
 */
export default function DvActions() {

  const onSaveAndPreview = () => {

  }

  const onSave = () => {
    let loading = prompt.loading('正在保存');
    store.saveCacheDvOption();
    setTimeout(() => {
      loading();
      prompt.success('保存成功！')
    }, 1000)
  }

  const onCancel = () => {
    prompt.confirm(() => {}, {
      title: '退出警告',
      content: '您将要退出编辑模式，请注意保存！'
    })
  }


  const actions = {
    onSaveAndPreview,
    onSave,
    onCancel
  };

  return <ul className={classnames(styles.toolbarUl,styles.dvActions)}>
    {
      Object.entries(EnumDvActions).map(([key, value])=> <li
        key={key}
        // title={value.label}
        onClick={actions[value.onClick]}
      >
        <IconFont type={value.icon} />
        <span>{value.label}</span>
      </li>)
    }
  </ul>
}
